var index=0;
//改变图片
function ChangeImg() {
    index++;
    var a=document.getElementsByClassName("img-slide");
    if(index>=a.length) index=1;
    for(var i=0;i<a.length;i++){

        a[i].style.display='block';
        a[index].style.display='none';
    }
}
//设置定时器，每隔两秒切换一张图片
setInterval(ChangeImg, 2000);



//注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
layui.use(['element','form','laypage','laydate','layedit','upload','laytpl'], function(){
    var element = layui.element;
    var laytpl = layui.laytpl;
    var upload = layui.upload;
    var form = layui.form;
    var laydate = layui.laydate;
    var laypage = layui.laypage;
    var data = {
        "list":[
                {"name":"系统主页","icon":"layui-icon-home","url":"AdminIndex"},
                {"name":"用户管理","icon":"layui-icon-friends","url":"Users"},
                {"name":"订单处理","icon":"layui-icon-tabs","url":"Order"},
                {"name":"影片仓库","icon":"layui-icon-video","url":"AdminMovie"},
                {"name":"我的影厅","icon":"layui-icon-component","url":"Studio"},
                {"name":"座位排表","icon":"layui-icon-cols","url":"AdminSeat"},
                {"name":"电影类型","icon":"layui-icon-slider","url":"MovieType"},
                {"name":"客户反馈","icon":"layui-icon-user","url":"Customer"},
            ]
    };
    
    var getTpl = side.innerHTML
        ,view = document.getElementById('leftside');
        laytpl(getTpl).render(data, function(html){
            view.innerHTML = html;
        });
    //执行实例
        var str = "";
        var uploadadd = upload.render({
        
        elem: '#newadd' //绑定元素
        ,url: '/SSM_CMS/updateImgs.do' //上传接口
        ,done: function(res){
        	if(res["state"]==1){
        		layer.msg('上传成功');
        		$('#ds').children().remove();
        		var imgs = res['names'];
        		 str += "<img  value='9999' src='http://localhost:8080/test/"+imgs+"' class='layui-nav-img '/>"
        		 str +="<input type='text' style='display:none' value='"+imgs+"'  name='imgs'/>"
        		$('#ds').append(str)
        	}else{
        		layer.msg('上传失败', {icon: 5,time: 800});
        	}
        }
    	,field: "imgsg"
    	,size :1024
        ,error: function(){
        	alert("失败")
        }
    });
 
        
    $('#user_name').html(eval("(" + $.cookie('admin_user') + ")")['users']);
    
    //添加分类
$("#addclass").click(function () {
        layer.open({
            title: '添加分类'
            ,type: 1
            ,content:$('#addclassform')
        });
        return false;
    });
    
    
    
 $(".userhead").click(function () {
        var imgpath = $(this).attr('src');
        layer.open({
            type: 1,
            shade:false,
            title: false, //不显示标题
            content: "<img src='"+ imgpath +"' width='100%'>"
        });
    });
});